import tkinter
# entry 输入文字的条子
window = tkinter.Tk()
window.title = ('窗口名字')
window.geometry("200x200")  # 设置窗口尺寸

var1 = tkinter.StringVar()


l=tkinter.Label(window,bg='yellow',width=4,textvariable=var1)
l.pack()

def print_selection():
    value = listbox.get(listbox.curselection())
    var1.set(value)

b1 = tkinter.Button(window, text='print selection', width=15, height=2, bg='green',command=print_selection)
b1.pack()

var2 = tkinter.StringVar()
var2.set((11,22,33,44))
listbox=tkinter.Listbox(window,listvariable=var2)
list_items = [1,2,3,4]
for item in list_items:
    listbox.insert('end',item)
listbox.insert(1,'first')
listbox.insert(2,'second')
listbox.delete(2)
listbox.pack()

window.mainloop()




